/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.ncsu.csc573.project1.gui;

/**
 *
 * @author svpendse1
 */
import java.awt.*;
import java.awt.event.*;
 
public class MySplashScreen extends Frame implements ActionListener {
    public static boolean active = true;
    public static String currentMessage = "";
    static void renderSplashFrame(Graphics2D g) {
        g.setComposite(AlphaComposite.Clear);
        g.fillRect(120,140,200,150);
        g.setPaintMode();
        Font textFont = new Font("Arial", Font.BOLD, 16); 
        g.setFont(textFont);
        g.setColor(Color.black);
        g.drawString(currentMessage, 160, 250);
    }
    
    public MySplashScreen() {
        super("SplashScreen demo");
        setSize(300, 200);
        
        final SplashScreen splash = SplashScreen.getSplashScreen();
        if (splash == null) {
            System.out.println("SplashScreen.getSplashScreen() returned null");
            return;
        }
        Graphics2D g = splash.createGraphics();
        if (g == null) {
            System.out.println("g is null");
            return;
        }
        while (active) {    
            renderSplashFrame(g);
            splash.update();
            try {
                Thread.sleep(50);
            }
            catch(InterruptedException e) {
            }
        }
        splash.close();
    }
    public void actionPerformed(ActionEvent ae) {
        System.exit(0);
    }
     
    private static WindowListener closeWindow = new WindowAdapter(){
        public void windowClosing(WindowEvent e){
            e.getWindow().dispose();
        }
    };
     
    public static void main (String args[]) {
        MySplashScreen.currentMessage = "Loading RFCs...";
        MySplashScreen test = new MySplashScreen();
    }
}
